package com.li.chat.controller;

import cn.hutool.core.io.FileUtil;
import com.li.chat.common.BaseResponse;
import com.li.chat.common.ErrorCode;
import com.li.chat.common.ResultUtils;
import com.li.chat.constant.FileConstant;
import com.li.chat.exception.BusinessException;
import com.li.chat.model.enums.FileUploadBizEnum;

import java.io.File;
import java.util.Arrays;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import com.li.chat.utils.MinioUntil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;


@RestController
@RequestMapping("/file")
@Slf4j
public class FileController {

    @Autowired
    private MinioUntil minioUntil;

    @PostMapping("/update")
    public Map<String,String> update(@RequestParam MultipartFile file) {
        return minioUntil.upload(file);
    }
    @PostMapping("/remove")
    public Map<String,String> remove(String file) {
        return minioUntil.removeObjects(file);
    }
}
